import { getUserAPI } from '../api/user'

export default {
  namespaced: true,
  state() {
    return {
      token: '',
      user: {}
    }
  },

  mutations: {
    updatedToken(state, val) {
      state.token = val
    },
    updatedget(state, val) {
      state.user = val
    }
  },

  actions: {
    async getUser(store) {
      const { data: res } = await getUserAPI()
      if (res.code === 0) {
        store.commit('updatedget', res.data)
      }
    }
  }
}
